<template>
    <AntdConfirmModal title="新建职级" ref="modalRef" @confirm="submitForm">
            <a-form :model="form" name="basic" :label-col="{ span: 6 }">
                <a-form-item label="职级分类" name="jobTypeId" >
                    <a-select placeholder="请选择职级分类" v-model:value="form.jobGradeTypeId" style="width: 200px"
                        :options="typeOptions">
                    </a-select>
                </a-form-item>
                <a-form-item label="职级名称" name="jobGradeName" :rules="[{ required: true, message: '请输入职级名称' }]">
                    <a-input v-model:value="form.jobGradeName" />
                </a-form-item>
                <a-form-item label="职级编码" name="jobGradeCode" :rules="[{ required: true, message: '请输入职级编码' }]">
                    <a-input v-model:value="form.jobGradeCode" />
                </a-form-item>
                <!-- <a-form-item label="职级系数" name="standard" :rules="[{ required: true, message: '请输入职级系数' }]">
                    <a-input-number v-model:value="form.standard" />
                </a-form-item> -->
                <a-form-item label="职级状态">
                    <a-switch v-model:checked="form.status" :checkedValue="1" :unCheckedValue="0" />
                </a-form-item>
                <a-form-item label="津贴系数" name="standard" :rules="[{ required: true, message: '津贴系数不可为空' }]">
                    <a-input-number v-model:value="form.standard" />
                </a-form-item>
                <a-form-item label="职级排序" name="orderNum">
                    <a-input-number v-model:value="form.orderNum" />
                </a-form-item>
                <a-form-item :name="remark" label="备注">
                    <a-textarea v-model:value="form.remark" />
                </a-form-item>
            </a-form>
        </AntdConfirmModal>
</template>
<script setup>
import {createOne} from '@/module/hrm/api/job_grade';
import userGradeStore from '@/module/hrm/store/grade';
const gradeStore = userGradeStore();
const typeOptions = computed(() => {
    let arr = $.freeStore(gradeStore.types);
    arr.map(ele => {
        ele.label = ele.typeName,
        ele.value = ele.id
    })
    return arr
})
import useApp from '@/hooks';
const { $ } = useApp();
const modalRef = ref(null);
const form = ref({
    jobGradeTypeId: undefined,
    jobGradeName: undefined,
    jobGradeCode: undefined,
    status: 1,
    orderNum: 1,
    standard:0.0
})
$.on('create-grade', res => {
    modalRef.value.openModal();
})
/** 提交按钮 */
function submitForm() {
    createOne(form.value).then(res => {
        console.log(res)
        $.showToast({
            title: '创建成功',
            icon: 'success'
        })
        $.emit('fresh-grade',null);
        modalRef.value.closeModal()
    })
}
</script>